﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace mo_phong_cac_thuat_toan_sap_xep
{
    class PhanTu : System.Windows.Forms.Label
    {
        public PhanTu()
        {
            this.AutoSize = false;
            this.BackColor = Color.Transparent;
            this.Font = new Font("Microsoft Sans Serif", 14);
            this.Image = Properties.Resources.red_button;
            this.ForeColor = Color.White;
            this.Size = new Size(48, 48);
            this.TextAlign = ContentAlignment.MiddleCenter;
        }

        public void DiLen(int iTocDo, int y = 1)
        {
            for (int i = 0; i < y; i++)
            {
                Application.DoEvents();
                Thread.Sleep(iTocDo);
                this.Location = new Point(this.Location.X, this.Location.Y - 1);
            }
        }

        public void DiXuong(int iTocDo, int y = 1)
        {
            for (int i = 0; i < y; i++)
            {
                Application.DoEvents();
                Thread.Sleep(iTocDo);
                this.Location = new Point(this.Location.X, this.Location.Y + 1);
            }
        }

        public void DiSangTrai(int iTocDo, int x = 1)
        {
            for (int i = 0; i < x; i++)
            {
                Application.DoEvents();
                Thread.Sleep(iTocDo);
                this.Location = new Point(this.Location.X - 1, this.Location.Y);
            }
        }

        public void DiSangPhai(int iTocDo, int x = 1)
        {
            for (int i = 0; i < x; i++)
            {
                Application.DoEvents();
                Thread.Sleep(iTocDo);
                this.Location = new Point(this.Location.X + 1, this.Location.Y);
            }
        }

        public void SangPhaiDenViTriX(int iTocDo, int toaDoX, int toaDoY)
        {

            for (int i = this.Location.X; i < toaDoX; i++)
            {
                Application.DoEvents();
                Thread.Sleep(iTocDo);
                this.Location = new Point(i, toaDoY);
            }
        }

    }
}